package com.tjbklx1.thread.chap01.demo01;

public class Gate {
	private int counter = 0;
	private String name = "NoBody";
	private String addr = "NoWhere";

	public synchronized void pass(String name, String addr) {
		this.counter++;
		this.name = name;
		this.addr = addr;
		check();
	}

	private void check() {
		if (name.charAt(0) != addr.charAt(0)) {
			System.out.println("********Broken*******" + toString());
		}

	}

	@Override
	public synchronized String toString() {
		return "No." + counter + " : " + name + " : " + addr;
	}

}
